package org.example.iocdemo.ioc.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * Created with IntelliJ IDEA.
 * Description:做渐进主义的改良派,不做完没注意的速成派
 * User: XALEXC
 * Date: 2024-11-04
 * Time: 17:17
 */
@Configuration
public class BeanConfig {
    @Bean
    public String name2(){
        return "wangwu";
    }

  /*  @Bean
    public String name(){
        return "lisi";
    }*/

    @Primary
    @Bean
    public UserInfo userInfo1(String name){
        UserInfo userInfo = new UserInfo();
        userInfo.setId(1);
        userInfo.setName(name);
        userInfo.setAge(12);
        return userInfo;
    }

    @Bean
    public UserInfo userInfo2(){
        UserInfo userInfo = new UserInfo();
        userInfo.setId(2);
        userInfo.setName("lisi");
        userInfo.setAge(13);
        return userInfo;
    }
}
